<?php
require_once "checklogin.php";
require_once "../lib/MySQLDB.class.php";
$db=MySQLDB::getInstance();
if(!empty($_POST)){
    $data=$_POST;
    $data["id"]=$_GET['id'];
    $sql="update category set cName=?,pid=? where id=?";
    $res=$db->query($sql,"ssi",$data);
    if($res){
        layerAlert("类别修改成功！",1,"catelist.php");
    }else{
        layerAlert("类别修改失败！",5,"catelist.php");
    }
}else{
    $sql="select * from category order  by id asc";
    $rows=$db->fetchAll($sql);
    $cataArr=getSubTree($rows,0,0);
    $data["id"]=$_GET['id'];
    $sql="select * from category where id=?";
    $row=$db->fetchRow($sql,"i",$data);
    require_once "view/cateEdit.html";
}
